{% extends 'base.html' %}
{% load static %}
{% block css %}
     <link rel="stylesheet" type="text/css" href="{% static 'assets/select2/select2.css' %}" />
{% endblock %}
{% block title %}
    添加主机
{% endblock %}
{% block page-title %}
    添加主机
{% endblock %}
{% block page-content %}
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">添加一个或多个用户到角色</h3>
                </div>
                <div class="panel-body">
                    {% if messages %}
                        {% for message in messages %}
                            <div class="alert alert-{{ message.tags }} alert-dismissable">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                {{ message }}
                            </div>
                        {% endfor %}
                    {% endif %}
                    <form class="form-horizontal" role="form" action="" method="post">
                        {% csrf_token %}
                        <div class="form-group">
                            <label class="col-sm-3 control-label">主机：</label>
                            <div class="col-sm-9">
                                <select class="select2" name="hosts" multiple data-placeholder="添加一个或多个主机...">
                                    {% for host in hosts %}
                                        <option value="{{ host.id }}" {% for select_host in selected_hosts %}{% ifequal select_host.id host.id %}selected{% endifequal %}{% endfor %}>{{ host.instance_name }}</option>
                                    {% endfor %}
                                </select>
                            </div>
                        </div>
                        <div class="form-group m-b-0">
                            <div class="col-sm-offset-3 col-sm-9">
                              <button type="submit" name="_save" class="btn btn-primary">保存</button>
                              <button type="submit" name="_addanother"  class="btn btn-primary">保存并继续编辑</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block js %}
     <script src="{% static 'assets/select2/select2.min.js' %}" type="text/javascript"></script>
    <script>
        jQuery(".select2").select2({
            width: '100%'
        });
    </script>
     <script>
        $('.taggit').addClass('active');
        $('.taggit .tags').addClass('active');
    </script>
{% endblock %}
